<template>
  <div>
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>活动管理</el-breadcrumb-item>
      <el-breadcrumb-item>活动列表</el-breadcrumb-item>
      <el-breadcrumb-item>活动详情</el-breadcrumb-item>
    </el-breadcrumb>
    <el-row>
      <el-col :span="13">
        <el-input
          placeholder="请输入搜索内容"
          v-model="page.query"
          class="input-with-select"
        >
          <el-button
            slot="append"
            icon="el-icon-search"
            @click="searchFn"
          ></el-button>
        </el-input>
      </el-col>
    </el-row>
    <el-table border :data="OrderList">
      <el-table-column label="#" prop="order_number"></el-table-column>
      <el-table-column label="订单价格" prop="order_price"></el-table-column>
      <el-table-column label="是否付款" prop="order_pay">
        <template slot-scope="scope">
          <el-tag :type="scope.row.order_pay == 0 ? 'danger' : 'success'">{{
            scope.row.order_pay == 0 ? "未付款" : "已付款"
          }}</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="是否发货" prop="is_send"></el-table-column>
      <el-table-column label="下单时间" prop="create_time">
        <template slot-scope="scope">
          {{ scope.row.create_time | timer }}
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button
            type="primary"
            icon="el-icon-edit"
            size="mini"
            @click="dialogEditVisible = true"
          ></el-button>
          <el-button
            type="success"
            icon="el-icon-location-outline"
            size="mini"
            @click="dialogStreamVisible = true"
          ></el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="page.pagenum"
      :page-sizes="[5, 10, 15, 30]"
      :page-size="page.pagesize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
    >
    </el-pagination>

    <!-- 修改地址的弹出框 -->
    <el-dialog title="修改地址" :visible.sync="dialogEditVisible">
      <el-form :model="Editform" :rules="rules" ref="Editform">
        <el-form-item label="省市区/县">
          <el-cascader
            :options="options"
            :props="addressProps"
            clearable
          ></el-cascader>
        </el-form-item>
        <el-form-item label="详细地址" prop="address">
          <el-input v-model="Editform.address" autocomplete="off"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogEditVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogEditVisible = false"
          >确 定</el-button
        >
      </div>
    </el-dialog>
    <!-- //物流信息 -->
    <el-dialog title="物流进度" :visible.sync="dialogStreamVisible">
      <el-timeline :reverse="reverse">
        <el-timeline-item
          v-for="(activity, index) in activities"
          :key="index"
          :timestamp="activity.time"
        >
          {{ activity.context }}
        </el-timeline-item>
      </el-timeline>
    </el-dialog>
  </div>
</template>
<script>
import { orderListfn } from "@/http/Order";
import { china } from "../tool/china";
import {kuaidi} from '../tool/kuaidi'
export default {
  data() {
    return {
      search: "",
      OrderList: [],
      page: {
        pagenum: 1,
        pagesize: 10,
        query: "",
      },
      total: 0,
      dialogEditVisible: false,

      Editform: {
        address: "",
      },
      options: china,
      addressProps: {
        checkStrictly: true,
        value: "code",
        label: "value",
      },
      rules: {
        address: [
          { required: true, message: "请输入活动名称", trigger: "blur" },
          { min: 3, max: 5, message: "长度在 3 到 5 个字符", trigger: "blur" },
        ],
      },
      dialogStreamVisible: false,
      reverse: true,
      activities:kuaidi.data,
     
    };
  },
  methods: {
    searchFn() {
      this.orderFn();
    },
    async orderFn() {
      let res = await orderListfn({
        query: this.page.query,
        pagenum: this.page.pagenum,
        pagesize: this.page.pagesize,
      });
      this.OrderList = res.data.goods;
      this.total = res.data.total;
      console.log(res);
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
      this.page.pagesize = val;
      this.orderFn();
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.page.pagenum = val;
      this.orderFn();
    },
  },
  created() {
    this.orderFn();
  },
};
</script>
<style lang='scss'>
.el-row {
  // 上右下左
  margin: 10px 0;
}
.el-cascader-panel {
  height: 300px;
}
</style>